﻿CREATE FUNCTION [dbo].[GetChapterCost]
(
	@chapterId UNIQUEIDENTIFIER
	,	@userId UNIQUEIDENTIFIER = NULL
	,	@cost NVARCHAR(128) = NULL
)
RETURNS NVARCHAR(128)
AS
BEGIN
/*	IF	@cost IS NULL 
			OR
				(	SELECT COUNT(*)
					FROM [dbo].[user_Role] AS r 
					INNER JOIN [dbo].[user_User] AS u ON u.[Email] = r.[Email]
					WHERE u.[UserId] = @userId AND r.[Role] IN ('Admin')) > 0
		RETURN NULL
	ELSE IF (SELECT COUNT(*) 
					FROM [dbo].[purchase_Item] 
					WHERE [ChapterId] = @chapterId 
								AND [UserId] = @userId 
								AND [PurchaseStatusId] = 1) > 0
	BEGIN 
		SET @cost = -1
	END

	RETURN @cost
*/
	RETURN N'-1'
END
